{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 本周内容：堆叠图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <a href=\"https://bokeh.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
       "        <span id=\"1001\">Loading BokehJS ...</span>\n",
       "    </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "\n",
       "(function(root) {\n",
       "  function now() {\n",
       "    return new Date();\n",
       "  }\n",
       "\n",
       "  var force = true;\n",
       "\n",
       "  if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n",
       "    root._bokeh_onload_callbacks = [];\n",
       "    root._bokeh_is_loading = undefined;\n",
       "  }\n",
       "\n",
       "  var JS_MIME_TYPE = 'application/javascript';\n",
       "  var HTML_MIME_TYPE = 'text/html';\n",
       "  var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
       "  var CLASS_NAME = 'output_bokeh rendered_html';\n",
       "\n",
       "  /**\n",
       "   * Render data to the DOM node\n",
       "   */\n",
       "  function render(props, node) {\n",
       "    var script = document.createElement(\"script\");\n",
       "    node.appendChild(script);\n",
       "  }\n",
       "\n",
       "  /**\n",
       "   * Handle when an output is cleared or removed\n",
       "   */\n",
       "  function handleClearOutput(event, handle) {\n",
       "    var cell = handle.cell;\n",
       "\n",
       "    var id = cell.output_area._bokeh_element_id;\n",
       "    var server_id = cell.output_area._bokeh_server_id;\n",
       "    // Clean up Bokeh references\n",
       "    if (id != null && id in Bokeh.index) {\n",
       "      Bokeh.index[id].model.document.clear();\n",
       "      delete Bokeh.index[id];\n",
       "    }\n",
       "\n",
       "    if (server_id !== undefined) {\n",
       "      // Clean up Bokeh references\n",
       "      var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
       "      cell.notebook.kernel.execute(cmd, {\n",
       "        iopub: {\n",
       "          output: function(msg) {\n",
       "            var id = msg.content.text.trim();\n",
       "            if (id in Bokeh.index) {\n",
       "              Bokeh.index[id].model.document.clear();\n",
       "              delete Bokeh.index[id];\n",
       "            }\n",
       "          }\n",
       "        }\n",
       "      });\n",
       "      // Destroy server and session\n",
       "      var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
       "      cell.notebook.kernel.execute(cmd);\n",
       "    }\n",
       "  }\n",
       "\n",
       "  /**\n",
       "   * Handle when a new output is added\n",
       "   */\n",
       "  function handleAddOutput(event, handle) {\n",
       "    var output_area = handle.output_area;\n",
       "    var output = handle.output;\n",
       "\n",
       "    // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
       "    if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
       "      return\n",
       "    }\n",
       "\n",
       "    var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
       "\n",
       "    if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
       "      toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
       "      // store reference to embed id on output_area\n",
       "      output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
       "    }\n",
       "    if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
       "      var bk_div = document.createElement(\"div\");\n",
       "      bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
       "      var script_attrs = bk_div.children[0].attributes;\n",
       "      for (var i = 0; i < script_attrs.length; i++) {\n",
       "        toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
       "        toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n",
       "      }\n",
       "      // store reference to server id on output_area\n",
       "      output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function register_renderer(events, OutputArea) {\n",
       "\n",
       "    function append_mime(data, metadata, element) {\n",
       "      // create a DOM node to render to\n",
       "      var toinsert = this.create_output_subarea(\n",
       "        metadata,\n",
       "        CLASS_NAME,\n",
       "        EXEC_MIME_TYPE\n",
       "      );\n",
       "      this.keyboard_manager.register_events(toinsert);\n",
       "      // Render to node\n",
       "      var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
       "      render(props, toinsert[toinsert.length - 1]);\n",
       "      element.append(toinsert);\n",
       "      return toinsert\n",
       "    }\n",
       "\n",
       "    /* Handle when an output is cleared or removed */\n",
       "    events.on('clear_output.CodeCell', handleClearOutput);\n",
       "    events.on('delete.Cell', handleClearOutput);\n",
       "\n",
       "    /* Handle when a new output is added */\n",
       "    events.on('output_added.OutputArea', handleAddOutput);\n",
       "\n",
       "    /**\n",
       "     * Register the mime type and append_mime function with output_area\n",
       "     */\n",
       "    OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
       "      /* Is output safe? */\n",
       "      safe: true,\n",
       "      /* Index of renderer in `output_area.display_order` */\n",
       "      index: 0\n",
       "    });\n",
       "  }\n",
       "\n",
       "  // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
       "  if (root.Jupyter !== undefined) {\n",
       "    var events = require('base/js/events');\n",
       "    var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
       "\n",
       "    if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
       "      register_renderer(events, OutputArea);\n",
       "    }\n",
       "  }\n",
       "\n",
       "  \n",
       "  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "    root._bokeh_timeout = Date.now() + 5000;\n",
       "    root._bokeh_failed_load = false;\n",
       "  }\n",
       "\n",
       "  var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "     \"<div style='background-color: #fdd'>\\n\"+\n",
       "     \"<p>\\n\"+\n",
       "     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "     \"</p>\\n\"+\n",
       "     \"<ul>\\n\"+\n",
       "     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "     \"</ul>\\n\"+\n",
       "     \"<code>\\n\"+\n",
       "     \"from bokeh.resources import INLINE\\n\"+\n",
       "     \"output_notebook(resources=INLINE)\\n\"+\n",
       "     \"</code>\\n\"+\n",
       "     \"</div>\"}};\n",
       "\n",
       "  function display_loaded() {\n",
       "    var el = document.getElementById(\"1001\");\n",
       "    if (el != null) {\n",
       "      el.textContent = \"BokehJS is loading...\";\n",
       "    }\n",
       "    if (root.Bokeh !== undefined) {\n",
       "      if (el != null) {\n",
       "        el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
       "      }\n",
       "    } else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(display_loaded, 100)\n",
       "    }\n",
       "  }\n",
       "\n",
       "\n",
       "  function run_callbacks() {\n",
       "    try {\n",
       "      root._bokeh_onload_callbacks.forEach(function(callback) {\n",
       "        if (callback != null)\n",
       "          callback();\n",
       "      });\n",
       "    } finally {\n",
       "      delete root._bokeh_onload_callbacks\n",
       "    }\n",
       "    console.debug(\"Bokeh: all callbacks have finished\");\n",
       "  }\n",
       "\n",
       "  function load_libs(css_urls, js_urls, callback) {\n",
       "    if (css_urls == null) css_urls = [];\n",
       "    if (js_urls == null) js_urls = [];\n",
       "\n",
       "    root._bokeh_onload_callbacks.push(callback);\n",
       "    if (root._bokeh_is_loading > 0) {\n",
       "      console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "      return null;\n",
       "    }\n",
       "    if (js_urls == null || js_urls.length === 0) {\n",
       "      run_callbacks();\n",
       "      return null;\n",
       "    }\n",
       "    console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "    root._bokeh_is_loading = css_urls.length + js_urls.length;\n",
       "\n",
       "    function on_load() {\n",
       "      root._bokeh_is_loading--;\n",
       "      if (root._bokeh_is_loading === 0) {\n",
       "        console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n",
       "        run_callbacks()\n",
       "      }\n",
       "    }\n",
       "\n",
       "    function on_error() {\n",
       "      console.error(\"failed to load \" + url);\n",
       "    }\n",
       "\n",
       "    for (var i = 0; i < css_urls.length; i++) {\n",
       "      var url = css_urls[i];\n",
       "      const element = document.createElement(\"link\");\n",
       "      element.onload = on_load;\n",
       "      element.onerror = on_error;\n",
       "      element.rel = \"stylesheet\";\n",
       "      element.type = \"text/css\";\n",
       "      element.href = url;\n",
       "      console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n",
       "      document.body.appendChild(element);\n",
       "    }\n",
       "\n",
       "    const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n",
       "\n",
       "    for (var i = 0; i < js_urls.length; i++) {\n",
       "      var url = js_urls[i];\n",
       "      var element = document.createElement('script');\n",
       "      element.onload = on_load;\n",
       "      element.onerror = on_error;\n",
       "      element.async = false;\n",
       "      element.src = url;\n",
       "      if (url in hashes) {\n",
       "        element.crossOrigin = \"anonymous\";\n",
       "        element.integrity = \"sha384-\" + hashes[url];\n",
       "      }\n",
       "      console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "      document.head.appendChild(element);\n",
       "    }\n",
       "  };\n",
       "\n",
       "  function inject_raw_css(css) {\n",
       "    const element = document.createElement(\"style\");\n",
       "    element.appendChild(document.createTextNode(css));\n",
       "    document.body.appendChild(element);\n",
       "  }\n",
       "\n",
       "  \n",
       "  var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n",
       "  var css_urls = [];\n",
       "  \n",
       "\n",
       "  var inline_js = [\n",
       "    function(Bokeh) {\n",
       "      Bokeh.set_log_level(\"info\");\n",
       "    },\n",
       "    function(Bokeh) {\n",
       "    \n",
       "    \n",
       "    }\n",
       "  ];\n",
       "\n",
       "  function run_inline_js() {\n",
       "    \n",
       "    if (root.Bokeh !== undefined || force === true) {\n",
       "      \n",
       "    for (var i = 0; i < inline_js.length; i++) {\n",
       "      inline_js[i].call(root, root.Bokeh);\n",
       "    }\n",
       "    if (force === true) {\n",
       "        display_loaded();\n",
       "      }} else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(run_inline_js, 100);\n",
       "    } else if (!root._bokeh_failed_load) {\n",
       "      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "      root._bokeh_failed_load = true;\n",
       "    } else if (force !== true) {\n",
       "      var cell = $(document.getElementById(\"1001\")).parents('.cell').data().cell;\n",
       "      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "    }\n",
       "\n",
       "  }\n",
       "\n",
       "  if (root._bokeh_is_loading === 0) {\n",
       "    console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "    run_inline_js();\n",
       "  } else {\n",
       "    load_libs(css_urls, js_urls, function() {\n",
       "      console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "      run_inline_js();\n",
       "    });\n",
       "  }\n",
       "}(window));"
      ],
      "application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n  function now() {\n    return new Date();\n  }\n\n  var force = true;\n\n  if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n    root._bokeh_onload_callbacks = [];\n    root._bokeh_is_loading = undefined;\n  }\n\n  \n\n  \n  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n    root._bokeh_timeout = Date.now() + 5000;\n    root._bokeh_failed_load = false;\n  }\n\n  var NB_LOAD_WARNING = {'data': {'text/html':\n     \"<div style='background-color: #fdd'>\\n\"+\n     \"<p>\\n\"+\n     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n     \"</p>\\n\"+\n     \"<ul>\\n\"+\n     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n     \"</ul>\\n\"+\n     \"<code>\\n\"+\n     \"from bokeh.resources import INLINE\\n\"+\n     \"output_notebook(resources=INLINE)\\n\"+\n     \"</code>\\n\"+\n     \"</div>\"}};\n\n  function display_loaded() {\n    var el = document.getElementById(\"1001\");\n    if (el != null) {\n      el.textContent = \"BokehJS is loading...\";\n    }\n    if (root.Bokeh !== undefined) {\n      if (el != null) {\n        el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n      }\n    } else if (Date.now() < root._bokeh_timeout) {\n      setTimeout(display_loaded, 100)\n    }\n  }\n\n\n  function run_callbacks() {\n    try {\n      root._bokeh_onload_callbacks.forEach(function(callback) {\n        if (callback != null)\n          callback();\n      });\n    } finally {\n      delete root._bokeh_onload_callbacks\n    }\n    console.debug(\"Bokeh: all callbacks have finished\");\n  }\n\n  function load_libs(css_urls, js_urls, callback) {\n    if (css_urls == null) css_urls = [];\n    if (js_urls == null) js_urls = [];\n\n    root._bokeh_onload_callbacks.push(callback);\n    if (root._bokeh_is_loading > 0) {\n      console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n      return null;\n    }\n    if (js_urls == null || js_urls.length === 0) {\n      run_callbacks();\n      return null;\n    }\n    console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n    root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n    function on_load() {\n      root._bokeh_is_loading--;\n      if (root._bokeh_is_loading === 0) {\n        console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n        run_callbacks()\n      }\n    }\n\n    function on_error() {\n      console.error(\"failed to load \" + url);\n    }\n\n    for (var i = 0; i < css_urls.length; i++) {\n      var url = css_urls[i];\n      const element = document.createElement(\"link\");\n      element.onload = on_load;\n      element.onerror = on_error;\n      element.rel = \"stylesheet\";\n      element.type = \"text/css\";\n      element.href = url;\n      console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n      document.body.appendChild(element);\n    }\n\n    const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\": \"kLr4fYcqcSpbuI95brIH3vnnYCquzzSxHPU6XGQCIkQRGJwhg0StNbj1eegrHs12\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\": \"xIGPmVtaOm+z0BqfSOMn4lOR6ciex448GIKG4eE61LsAvmGj48XcMQZtKcE/UXZe\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\": \"Dc9u1wF/0zApGIWoBbH77iWEHtdmkuYWG839Uzmv8y8yBLXebjO9ZnERsde5Ln/P\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\": \"cT9JaBz7GiRXdENrJLZNSC6eMNF3nh3fa5fTF51Svp+ukxPdwcU5kGXGPBgDCa2j\"};\n\n    for (var i = 0; i < js_urls.length; i++) {\n      var url = js_urls[i];\n      var element = document.createElement('script');\n      element.onload = on_load;\n      element.onerror = on_error;\n      element.async = false;\n      element.src = url;\n      if (url in hashes) {\n        element.crossOrigin = \"anonymous\";\n        element.integrity = \"sha384-\" + hashes[url];\n      }\n      console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n      document.head.appendChild(element);\n    }\n  };\n\n  function inject_raw_css(css) {\n    const element = document.createElement(\"style\");\n    element.appendChild(document.createTextNode(css));\n    document.body.appendChild(element);\n  }\n\n  \n  var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.1.1.min.js\"];\n  var css_urls = [];\n  \n\n  var inline_js = [\n    function(Bokeh) {\n      Bokeh.set_log_level(\"info\");\n    },\n    function(Bokeh) {\n    \n    \n    }\n  ];\n\n  function run_inline_js() {\n    \n    if (root.Bokeh !== undefined || force === true) {\n      \n    for (var i = 0; i < inline_js.length; i++) {\n      inline_js[i].call(root, root.Bokeh);\n    }\n    if (force === true) {\n        display_loaded();\n      }} else if (Date.now() < root._bokeh_timeout) {\n      setTimeout(run_inline_js, 100);\n    } else if (!root._bokeh_failed_load) {\n      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n      root._bokeh_failed_load = true;\n    } else if (force !== true) {\n      var cell = $(document.getElementById(\"1001\")).parents('.cell').data().cell;\n      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n    }\n\n  }\n\n  if (root._bokeh_is_loading === 0) {\n    console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n    run_inline_js();\n  } else {\n    load_libs(css_urls, js_urls, function() {\n      console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n      run_inline_js();\n    });\n  }\n}(window));"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from bokeh.plotting import output_notebook,figure,show\n",
    "output_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 数据准备模块 ColumnDataSource\n",
    "from bokeh.models import ColumnDataSource\n",
    "from bokeh.palettes import Spectral3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 数据准备\n",
    "from bokeh.core.properties import value\n",
    "fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']\n",
    "years = [\"2015\",\"2016\",\"2017\"]\n",
    "colors = Spectral3    # 颜色准备\n",
    "\n",
    "# 堆叠数据准备\n",
    "data = {'fruits' : fruits,\n",
    "        '2015'   : [2, 1, 4, 3, 2, 4],\n",
    "        '2016'   : [5, 3, 4, 2, 4, 6],\n",
    "        '2017'   : [3, 2, 4, 4, 5, 3]}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "source = ColumnDataSource(\n",
    "    data=data\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# 画布\n",
    "p = figure(\n",
    "    x_range=fruits, \n",
    "    plot_height=300, \n",
    "    title=\"Fruit Counts by Year\",\n",
    "    tooltips=\"$name @fruits: @$name\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"71ffcfa8-8ff6-42a1-841c-08b86ec342a7\" data-root-id=\"1290\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  var docs_json = {\"9478591a-4915-4616-a0e9-9b600d967847\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1301\"}],\"center\":[{\"id\":\"1303\"},{\"id\":\"1307\"},{\"id\":\"1343\"}],\"left\":[{\"id\":\"1304\"}],\"outline_line_color\":null,\"plot_height\":300,\"renderers\":[{\"id\":\"1333\"},{\"id\":\"1348\"},{\"id\":\"1362\"}],\"title\":{\"id\":\"1291\"},\"toolbar\":{\"id\":\"1316\"},\"x_range\":{\"id\":\"1293\"},\"x_scale\":{\"id\":\"1297\"},\"y_range\":{\"id\":\"1295\"},\"y_scale\":{\"id\":\"1299\"}},\"id\":\"1290\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"fields\":[\"2015\",\"2016\"]},\"id\":\"1327\",\"type\":\"Stack\"},{\"attributes\":{\"data\":{\"2015\":[2,1,4,3,2,4],\"2016\":[5,3,4,2,4,6],\"2017\":[3,2,4,4,5,3],\"fruits\":[\"Apples\",\"Pears\",\"Nectarines\",\"Plums\",\"Grapes\",\"Strawberries\"]},\"selected\":{\"id\":\"1195\"},\"selection_policy\":{\"id\":\"1194\"}},\"id\":\"1144\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"fields\":[]},\"id\":\"1324\",\"type\":\"Stack\"},{\"attributes\":{\"data_source\":{\"id\":\"1144\"},\"glyph\":{\"id\":\"1346\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2016\",\"nonselection_glyph\":{\"id\":\"1347\"},\"selection_glyph\":null,\"view\":{\"id\":\"1349\"}},\"id\":\"1348\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"axis\":{\"id\":\"1304\"},\"dimension\":1,\"ticker\":null},\"id\":\"1307\",\"type\":\"Grid\"},{\"attributes\":{\"callback\":null,\"tooltips\":\"$name @fruits: @$name\"},\"id\":\"1315\",\"type\":\"HoverTool\"},{\"attributes\":{\"label\":{\"value\":\"2015\"},\"renderers\":[{\"id\":\"1333\"}]},\"id\":\"1344\",\"type\":\"LegendItem\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1314\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"fields\":[\"2015\"]},\"id\":\"1325\",\"type\":\"Stack\"},{\"attributes\":{},\"id\":\"1194\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"label\":{\"value\":\"2017\"},\"renderers\":[{\"id\":\"1362\"}]},\"id\":\"1372\",\"type\":\"LegendItem\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1308\"},{\"id\":\"1309\"},{\"id\":\"1310\"},{\"id\":\"1311\"},{\"id\":\"1312\"},{\"id\":\"1313\"},{\"id\":\"1315\"}]},\"id\":\"1316\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1313\",\"type\":\"HelpTool\"},{\"attributes\":{\"fields\":[\"2015\",\"2016\"]},\"id\":\"1328\",\"type\":\"Stack\"},{\"attributes\":{\"overlay\":{\"id\":\"1314\"}},\"id\":\"1310\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1324\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#99d594\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#99d594\"},\"top\":{\"expr\":{\"id\":\"1325\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"fruits\"}},\"id\":\"1332\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1311\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1305\",\"type\":\"BasicTicker\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1328\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#fc8d59\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#fc8d59\"},\"top\":{\"expr\":{\"id\":\"1329\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"fruits\"}},\"id\":\"1361\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1312\",\"type\":\"ResetTool\"},{\"attributes\":{\"label\":{\"value\":\"2016\"},\"renderers\":[{\"id\":\"1348\"}]},\"id\":\"1358\",\"type\":\"LegendItem\"},{\"attributes\":{\"data_source\":{\"id\":\"1144\"},\"glyph\":{\"id\":\"1331\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2015\",\"nonselection_glyph\":{\"id\":\"1332\"},\"selection_glyph\":null,\"view\":{\"id\":\"1334\"}},\"id\":\"1333\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"text\":\"Fruit Counts by Year\"},\"id\":\"1291\",\"type\":\"Title\"},{\"attributes\":{\"fields\":[\"2015\",\"2016\",\"2017\"]},\"id\":\"1329\",\"type\":\"Stack\"},{\"attributes\":{\"source\":{\"id\":\"1144\"}},\"id\":\"1363\",\"type\":\"CDSView\"},{\"attributes\":{\"source\":{\"id\":\"1144\"}},\"id\":\"1349\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1339\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{},\"id\":\"1299\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1297\",\"type\":\"CategoricalScale\"},{\"attributes\":{},\"id\":\"1337\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"formatter\":{\"id\":\"1339\"},\"minor_tick_line_color\":null,\"ticker\":{\"id\":\"1302\"}},\"id\":\"1301\",\"type\":\"CategoricalAxis\"},{\"attributes\":{},\"id\":\"1309\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"items\":[{\"id\":\"1344\"},{\"id\":\"1358\"},{\"id\":\"1372\"}],\"location\":\"top_left\",\"orientation\":\"horizontal\"},\"id\":\"1343\",\"type\":\"Legend\"},{\"attributes\":{\"factors\":[\"Apples\",\"Pears\",\"Nectarines\",\"Plums\",\"Grapes\",\"Strawberries\"],\"range_padding\":0.1},\"id\":\"1293\",\"type\":\"FactorRange\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1326\"}},\"fill_color\":{\"value\":\"#ffffbf\"},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"1327\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"fruits\"}},\"id\":\"1346\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"2015\"]},\"id\":\"1326\",\"type\":\"Stack\"},{\"attributes\":{\"data_source\":{\"id\":\"1144\"},\"glyph\":{\"id\":\"1360\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2017\",\"nonselection_glyph\":{\"id\":\"1361\"},\"selection_glyph\":null,\"view\":{\"id\":\"1363\"}},\"id\":\"1362\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1308\",\"type\":\"PanTool\"},{\"attributes\":{\"end\":16,\"start\":0},\"id\":\"1295\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1302\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"axis\":{\"id\":\"1301\"},\"grid_line_color\":null,\"ticker\":null},\"id\":\"1303\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"1337\"},\"minor_tick_line_color\":null,\"ticker\":{\"id\":\"1305\"}},\"id\":\"1304\",\"type\":\"LinearAxis\"},{\"attributes\":{\"source\":{\"id\":\"1144\"}},\"id\":\"1334\",\"type\":\"CDSView\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1324\"}},\"fill_color\":{\"value\":\"#99d594\"},\"line_color\":{\"value\":\"#99d594\"},\"top\":{\"expr\":{\"id\":\"1325\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"fruits\"}},\"id\":\"1331\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1195\",\"type\":\"Selection\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1328\"}},\"fill_color\":{\"value\":\"#fc8d59\"},\"line_color\":{\"value\":\"#fc8d59\"},\"top\":{\"expr\":{\"id\":\"1329\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"fruits\"}},\"id\":\"1360\",\"type\":\"VBar\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1326\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#ffffbf\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"1327\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"fruits\"}},\"id\":\"1347\",\"type\":\"VBar\"}],\"root_ids\":[\"1290\"]},\"title\":\"Bokeh Application\",\"version\":\"2.1.1\"}};\n",
       "  var render_items = [{\"docid\":\"9478591a-4915-4616-a0e9-9b600d967847\",\"root_ids\":[\"1290\"],\"roots\":{\"1290\":\"71ffcfa8-8ff6-42a1-841c-08b86ec342a7\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        clearInterval(timer);\n",
       "        embed_document(root);\n",
       "      } else {\n",
       "        attempts++;\n",
       "        if (attempts > 100) {\n",
       "          clearInterval(timer);\n",
       "          console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        }\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "1290"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘图\n",
    "p.vbar_stack(\n",
    "    years, \n",
    "    x='fruits', \n",
    "    width=0.9, \n",
    "    color=colors, \n",
    "    source=source,\n",
    "    legend=[value(x) for x in years]    \n",
    ")\n",
    "\n",
    "# 其他\n",
    "p.y_range.start = 0\n",
    "p.y_range.end = 16\n",
    "p.x_range.range_padding = 0.1\n",
    "p.xgrid.grid_line_color = None\n",
    "p.axis.minor_tick_line_color = None\n",
    "p.outline_line_color = None\n",
    "p.legend.location = \"top_left\"\n",
    "p.legend.orientation = \"horizontal\"\n",
    "\n",
    "# 显示\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 实践练习  \n",
    "> 1.筛选数据：居民人均可支配收入累计值（元）\n",
    "> 2. 堆叠：5个季度的时间顺序\n",
    "> 3. x轴：地区"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>指标</th>\n",
       "      <th>2022年第一季度</th>\n",
       "      <th>2021年第四季度</th>\n",
       "      <th>2021年第三季度</th>\n",
       "      <th>2021年第二季度</th>\n",
       "      <th>2021年第一季度</th>\n",
       "      <th>地区</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>13360</td>\n",
       "      <td>44993</td>\n",
       "      <td>35694</td>\n",
       "      <td>23604</td>\n",
       "      <td>12636</td>\n",
       "      <td>广东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>城镇居民人均可支配收入累计值(元)</td>\n",
       "      <td>16230</td>\n",
       "      <td>54854</td>\n",
       "      <td>43592</td>\n",
       "      <td>28897</td>\n",
       "      <td>15472</td>\n",
       "      <td>广东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>农村居民人均可支配收入累计值(元)</td>\n",
       "      <td>6639</td>\n",
       "      <td>22306</td>\n",
       "      <td>17619</td>\n",
       "      <td>11490</td>\n",
       "      <td>6225</td>\n",
       "      <td>广东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>20630</td>\n",
       "      <td>75002</td>\n",
       "      <td>56498</td>\n",
       "      <td>38138</td>\n",
       "      <td>19585</td>\n",
       "      <td>北京</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>城镇居民人均可支配收入累计值(元)</td>\n",
       "      <td>22274</td>\n",
       "      <td>81518</td>\n",
       "      <td>61243</td>\n",
       "      <td>41381</td>\n",
       "      <td>21189</td>\n",
       "      <td>北京</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>农村居民人均可支配收入累计值(元)</td>\n",
       "      <td>10016</td>\n",
       "      <td>33303</td>\n",
       "      <td>26125</td>\n",
       "      <td>17383</td>\n",
       "      <td>9326</td>\n",
       "      <td>北京</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>22663</td>\n",
       "      <td>78027</td>\n",
       "      <td>58907</td>\n",
       "      <td>40357</td>\n",
       "      <td>21548</td>\n",
       "      <td>上海市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>城镇居民人均可支配收入累计值(元)</td>\n",
       "      <td>23772</td>\n",
       "      <td>82429</td>\n",
       "      <td>61915</td>\n",
       "      <td>42348</td>\n",
       "      <td>22636</td>\n",
       "      <td>上海市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>农村居民人均可支配收入累计值(元)</td>\n",
       "      <td>12891</td>\n",
       "      <td>38521</td>\n",
       "      <td>31985</td>\n",
       "      <td>22535</td>\n",
       "      <td>12006</td>\n",
       "      <td>上海市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>19366</td>\n",
       "      <td>57541</td>\n",
       "      <td>44712</td>\n",
       "      <td>30998</td>\n",
       "      <td>18263</td>\n",
       "      <td>浙江省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>城镇居民人均可支配收入累计值(元)</td>\n",
       "      <td>22784</td>\n",
       "      <td>68487</td>\n",
       "      <td>52758</td>\n",
       "      <td>36294</td>\n",
       "      <td>21600</td>\n",
       "      <td>浙江省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>农村居民人均可支配收入累计值(元)</td>\n",
       "      <td>12541</td>\n",
       "      <td>35247</td>\n",
       "      <td>28474</td>\n",
       "      <td>20357</td>\n",
       "      <td>11686</td>\n",
       "      <td>浙江省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>16490</td>\n",
       "      <td>47498</td>\n",
       "      <td>36227</td>\n",
       "      <td>25119</td>\n",
       "      <td>15500</td>\n",
       "      <td>江苏省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>城镇居民人均可支配收入累计值(元)</td>\n",
       "      <td>19251</td>\n",
       "      <td>57743</td>\n",
       "      <td>44267</td>\n",
       "      <td>30491</td>\n",
       "      <td>18194</td>\n",
       "      <td>江苏省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>农村居民人均可支配收入累计值(元)</td>\n",
       "      <td>10952</td>\n",
       "      <td>26791</td>\n",
       "      <td>20267</td>\n",
       "      <td>14455</td>\n",
       "      <td>10215</td>\n",
       "      <td>江苏省</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   指标  2022年第一季度  2021年第四季度  2021年第三季度  2021年第二季度  2021年第一季度  \\\n",
       "0     居民人均可支配收入累计值(元)      13360      44993      35694      23604      12636   \n",
       "1   城镇居民人均可支配收入累计值(元)      16230      54854      43592      28897      15472   \n",
       "2   农村居民人均可支配收入累计值(元)       6639      22306      17619      11490       6225   \n",
       "3     居民人均可支配收入累计值(元)      20630      75002      56498      38138      19585   \n",
       "4   城镇居民人均可支配收入累计值(元)      22274      81518      61243      41381      21189   \n",
       "5   农村居民人均可支配收入累计值(元)      10016      33303      26125      17383       9326   \n",
       "6     居民人均可支配收入累计值(元)      22663      78027      58907      40357      21548   \n",
       "7   城镇居民人均可支配收入累计值(元)      23772      82429      61915      42348      22636   \n",
       "8   农村居民人均可支配收入累计值(元)      12891      38521      31985      22535      12006   \n",
       "9     居民人均可支配收入累计值(元)      19366      57541      44712      30998      18263   \n",
       "10  城镇居民人均可支配收入累计值(元)      22784      68487      52758      36294      21600   \n",
       "11  农村居民人均可支配收入累计值(元)      12541      35247      28474      20357      11686   \n",
       "12    居民人均可支配收入累计值(元)      16490      47498      36227      25119      15500   \n",
       "13  城镇居民人均可支配收入累计值(元)      19251      57743      44267      30491      18194   \n",
       "14  农村居民人均可支配收入累计值(元)      10952      26791      20267      14455      10215   \n",
       "\n",
       "     地区  \n",
       "0   广东省  \n",
       "1   广东省  \n",
       "2   广东省  \n",
       "3    北京  \n",
       "4    北京  \n",
       "5    北京  \n",
       "6   上海市  \n",
       "7   上海市  \n",
       "8   上海市  \n",
       "9   浙江省  \n",
       "10  浙江省  \n",
       "11  浙江省  \n",
       "12  江苏省  \n",
       "13  江苏省  \n",
       "14  江苏省  "
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 数据准备\n",
    "import pandas as pd\n",
    "df = pd.read_csv('C:/Users/Daisy.C/Desktop/课件/python数据可视化/week09/居民人均可支配收入.csv')\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>指标</th>\n",
       "      <th>2022年第一季度</th>\n",
       "      <th>2021年第四季度</th>\n",
       "      <th>2021年第三季度</th>\n",
       "      <th>2021年第二季度</th>\n",
       "      <th>2021年第一季度</th>\n",
       "      <th>地区</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>13360</td>\n",
       "      <td>44993</td>\n",
       "      <td>35694</td>\n",
       "      <td>23604</td>\n",
       "      <td>12636</td>\n",
       "      <td>广东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>20630</td>\n",
       "      <td>75002</td>\n",
       "      <td>56498</td>\n",
       "      <td>38138</td>\n",
       "      <td>19585</td>\n",
       "      <td>北京</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>22663</td>\n",
       "      <td>78027</td>\n",
       "      <td>58907</td>\n",
       "      <td>40357</td>\n",
       "      <td>21548</td>\n",
       "      <td>上海市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>19366</td>\n",
       "      <td>57541</td>\n",
       "      <td>44712</td>\n",
       "      <td>30998</td>\n",
       "      <td>18263</td>\n",
       "      <td>浙江省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>16490</td>\n",
       "      <td>47498</td>\n",
       "      <td>36227</td>\n",
       "      <td>25119</td>\n",
       "      <td>15500</td>\n",
       "      <td>江苏省</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 指标  2022年第一季度  2021年第四季度  2021年第三季度  2021年第二季度  2021年第一季度  \\\n",
       "0   居民人均可支配收入累计值(元)      13360      44993      35694      23604      12636   \n",
       "3   居民人均可支配收入累计值(元)      20630      75002      56498      38138      19585   \n",
       "6   居民人均可支配收入累计值(元)      22663      78027      58907      40357      21548   \n",
       "9   居民人均可支配收入累计值(元)      19366      57541      44712      30998      18263   \n",
       "12  居民人均可支配收入累计值(元)      16490      47498      36227      25119      15500   \n",
       "\n",
       "     地区  \n",
       "0   广东省  \n",
       "3    北京  \n",
       "6   上海市  \n",
       "9   浙江省  \n",
       "12  江苏省  "
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "居民人均可支配收入累计值 = df.query('指标==\"居民人均可支配收入累计值(元)\"')\n",
    "居民人均可支配收入累计值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 数据准备\n",
    "from bokeh.core.properties import value\n",
    "from bokeh.palettes import Spectral5\n",
    "dq = ['广东省', '北京', '上海市', '浙江省', '江苏省']\n",
    "years = [\"2022Q1\",\"2021Q4\",\"2021Q3\",\"2021Q2\",\"2021Q1\"]\n",
    "colors = Spectral5    # 颜色准备\n",
    "\n",
    "Q1_2022 = 居民人均可支配收入累计值['2022年第一季度'].tolist()\n",
    "Q4_2021 = 居民人均可支配收入累计值['2021年第四季度'].tolist()\n",
    "Q3_2021 = 居民人均可支配收入累计值['2021年第三季度'].tolist()\n",
    "Q2_2021 = 居民人均可支配收入累计值['2021年第二季度'].tolist()\n",
    "Q1_2021 = 居民人均可支配收入累计值['2021年第一季度'].tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 堆叠数据准备\n",
    "shouru_data = {'dq' : dq,\n",
    "        '2022Q1'   : Q1_2022,\n",
    "        '2021Q4'   : Q4_2021,\n",
    "        '2021Q3'   : Q3_2021,\n",
    "        '2021Q2'   : Q2_2021,\n",
    "        '2021Q1'   : Q1_2021,}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "source = ColumnDataSource(\n",
    "    data=shouru_data\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 画布\n",
    "p = figure(\n",
    "    x_range=dq, \n",
    "    plot_height=300, \n",
    "    title=\"居民人均可支配收入累计值(元)\",\n",
    "    tooltips=\"可支配收入累计值 @dq: @$name\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"85e44f37-34cb-4f3b-9be2-567c7bf315d7\" data-root-id=\"4503\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  var docs_json = {\"5cccb0c6-738d-4a6a-a812-4691f4b9e1ae\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"4514\"}],\"center\":[{\"id\":\"4516\"},{\"id\":\"4520\"},{\"id\":\"4560\"}],\"left\":[{\"id\":\"4517\"}],\"outline_line_color\":null,\"plot_height\":300,\"renderers\":[{\"id\":\"4550\"},{\"id\":\"4565\"},{\"id\":\"4579\"},{\"id\":\"4593\"},{\"id\":\"4607\"},{\"id\":\"4727\"},{\"id\":\"4836\"},{\"id\":\"4945\"},{\"id\":\"5054\"},{\"id\":\"5163\"},{\"id\":\"5330\"},{\"id\":\"5439\"},{\"id\":\"5548\"},{\"id\":\"5657\"},{\"id\":\"5766\"},{\"id\":\"5933\"},{\"id\":\"6042\"},{\"id\":\"6151\"},{\"id\":\"6260\"},{\"id\":\"6369\"}],\"title\":{\"id\":\"4504\"},\"toolbar\":{\"id\":\"4529\"},\"x_range\":{\"id\":\"4506\"},\"x_scale\":{\"id\":\"4510\"},\"y_range\":{\"id\":\"4508\"},\"y_scale\":{\"id\":\"4512\"}},\"id\":\"4503\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"6370\",\"type\":\"CDSView\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"5328\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2022Q1\",\"nonselection_glyph\":{\"id\":\"5329\"},\"selection_glyph\":null,\"view\":{\"id\":\"5331\"}},\"id\":\"5330\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"axis\":{\"id\":\"4517\"},\"dimension\":1,\"ticker\":null},\"id\":\"4520\",\"type\":\"Grid\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4716\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#abdda4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#abdda4\"},\"top\":{\"expr\":{\"id\":\"4717\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"4835\",\"type\":\"VBar\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5321\"}},\"fill_color\":{\"value\":\"#ffffbf\"},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"5322\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"5546\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1502\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\",\"2021Q2\",\"2021Q1\"]},\"id\":\"5929\",\"type\":\"Stack\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"5055\",\"type\":\"CDSView\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5317\"}},\"fill_color\":{\"value\":\"#2b83ba\"},\"line_color\":{\"value\":\"#2b83ba\"},\"top\":{\"expr\":{\"id\":\"5318\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"5328\",\"type\":\"VBar\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5926\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#fdae61\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#fdae61\"},\"top\":{\"expr\":{\"id\":\"5927\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"6259\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\"]},\"id\":\"5926\",\"type\":\"Stack\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"6261\",\"type\":\"CDSView\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"6040\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021Q4\",\"nonselection_glyph\":{\"id\":\"6041\"},\"selection_glyph\":null,\"view\":{\"id\":\"6043\"}},\"id\":\"6042\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4714\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#2b83ba\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#2b83ba\"},\"top\":{\"expr\":{\"id\":\"4715\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"4726\",\"type\":\"VBar\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"5934\",\"type\":\"CDSView\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"6152\",\"type\":\"CDSView\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5920\"}},\"fill_color\":{\"value\":\"#2b83ba\"},\"line_color\":{\"value\":\"#2b83ba\"},\"top\":{\"expr\":{\"id\":\"5921\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"5931\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"2022Q1\"]},\"id\":\"5922\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\"]},\"id\":\"4540\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\",\"2021Q2\"]},\"id\":\"5325\",\"type\":\"Stack\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5319\"}},\"fill_color\":{\"value\":\"#abdda4\"},\"line_color\":{\"value\":\"#abdda4\"},\"top\":{\"expr\":{\"id\":\"5320\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"5437\",\"type\":\"VBar\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"5658\",\"type\":\"CDSView\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5928\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#d7191c\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#d7191c\"},\"top\":{\"expr\":{\"id\":\"5929\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"6368\",\"type\":\"VBar\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4545\"}},\"fill_color\":{\"value\":\"#d7191c\"},\"line_color\":{\"value\":\"#d7191c\"},\"top\":{\"expr\":{\"id\":\"4546\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"4605\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"2022Q1\"]},\"id\":\"4538\",\"type\":\"Stack\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"4608\",\"type\":\"CDSView\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"5164\",\"type\":\"CDSView\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"6258\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021Q2\",\"nonselection_glyph\":{\"id\":\"6259\"},\"selection_glyph\":null,\"view\":{\"id\":\"6261\"}},\"id\":\"6260\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4545\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#d7191c\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#d7191c\"},\"top\":{\"expr\":{\"id\":\"4546\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"4606\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"2022Q1\"]},\"id\":\"4539\",\"type\":\"Stack\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"5549\",\"type\":\"CDSView\"},{\"attributes\":{\"fields\":[]},\"id\":\"4537\",\"type\":\"Stack\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"5437\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021Q4\",\"nonselection_glyph\":{\"id\":\"5438\"},\"selection_glyph\":null,\"view\":{\"id\":\"5440\"}},\"id\":\"5439\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"6149\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021Q3\",\"nonselection_glyph\":{\"id\":\"6150\"},\"selection_glyph\":null,\"view\":{\"id\":\"6152\"}},\"id\":\"6151\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5922\"}},\"fill_color\":{\"value\":\"#abdda4\"},\"line_color\":{\"value\":\"#abdda4\"},\"top\":{\"expr\":{\"id\":\"5923\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"6040\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"4518\",\"type\":\"BasicTicker\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4722\"}},\"fill_color\":{\"value\":\"#d7191c\"},\"line_color\":{\"value\":\"#d7191c\"},\"top\":{\"expr\":{\"id\":\"4723\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"5161\",\"type\":\"VBar\"},{\"attributes\":{\"axis\":{\"id\":\"4514\"},\"grid_line_color\":null,\"ticker\":null},\"id\":\"4516\",\"type\":\"Grid\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5928\"}},\"fill_color\":{\"value\":\"#d7191c\"},\"line_color\":{\"value\":\"#d7191c\"},\"top\":{\"expr\":{\"id\":\"5929\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"6367\",\"type\":\"VBar\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"5546\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021Q3\",\"nonselection_glyph\":{\"id\":\"5547\"},\"selection_glyph\":null,\"view\":{\"id\":\"5549\"}},\"id\":\"5548\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"5440\",\"type\":\"CDSView\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\"]},\"id\":\"5923\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\",\"2021Q2\"]},\"id\":\"5324\",\"type\":\"Stack\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5317\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#2b83ba\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#2b83ba\"},\"top\":{\"expr\":{\"id\":\"5318\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"5329\",\"type\":\"VBar\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"6043\",\"type\":\"CDSView\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"4725\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2022Q1\",\"nonselection_glyph\":{\"id\":\"4726\"},\"selection_glyph\":null,\"view\":{\"id\":\"4728\"}},\"id\":\"4727\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5920\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#2b83ba\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#2b83ba\"},\"top\":{\"expr\":{\"id\":\"5921\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"5932\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\",\"2021Q2\"]},\"id\":\"5928\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\",\"2021Q2\",\"2021Q1\"]},\"id\":\"5326\",\"type\":\"Stack\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"5655\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021Q2\",\"nonselection_glyph\":{\"id\":\"5656\"},\"selection_glyph\":null,\"view\":{\"id\":\"5658\"}},\"id\":\"5657\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5924\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#ffffbf\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"5925\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"6150\",\"type\":\"VBar\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"4605\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021Q1\",\"nonselection_glyph\":{\"id\":\"4606\"},\"selection_glyph\":null,\"view\":{\"id\":\"4608\"}},\"id\":\"4607\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"5161\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021Q1\",\"nonselection_glyph\":{\"id\":\"5162\"},\"selection_glyph\":null,\"view\":{\"id\":\"5164\"}},\"id\":\"5163\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5924\"}},\"fill_color\":{\"value\":\"#ffffbf\"},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"5925\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"6149\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[]},\"id\":\"4714\",\"type\":\"Stack\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5323\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#fdae61\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#fdae61\"},\"top\":{\"expr\":{\"id\":\"5324\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"5656\",\"type\":\"VBar\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"4837\",\"type\":\"CDSView\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4722\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#d7191c\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#d7191c\"},\"top\":{\"expr\":{\"id\":\"4723\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"5162\",\"type\":\"VBar\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5922\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#abdda4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#abdda4\"},\"top\":{\"expr\":{\"id\":\"5923\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"6041\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"2022Q1\"]},\"id\":\"4715\",\"type\":\"Stack\"},{\"attributes\":{},\"id\":\"1503\",\"type\":\"Selection\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\"]},\"id\":\"4542\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[]},\"id\":\"5317\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"2022Q1\"]},\"id\":\"5318\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\"]},\"id\":\"5925\",\"type\":\"Stack\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4720\"}},\"fill_color\":{\"value\":\"#fdae61\"},\"line_color\":{\"value\":\"#fdae61\"},\"top\":{\"expr\":{\"id\":\"4721\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"5052\",\"type\":\"VBar\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5321\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#ffffbf\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"5322\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"5547\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\"]},\"id\":\"5320\",\"type\":\"Stack\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"4834\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021Q4\",\"nonselection_glyph\":{\"id\":\"4835\"},\"selection_glyph\":null,\"view\":{\"id\":\"4837\"}},\"id\":\"4836\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\"]},\"id\":\"4541\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[]},\"id\":\"5920\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"2022Q1\"]},\"id\":\"5319\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\"]},\"id\":\"5321\",\"type\":\"Stack\"},{\"attributes\":{\"formatter\":{\"id\":\"4554\"},\"minor_tick_line_color\":null,\"ticker\":{\"id\":\"4518\"}},\"id\":\"4517\",\"type\":\"LinearAxis\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\"]},\"id\":\"5322\",\"type\":\"Stack\"},{\"attributes\":{\"text\":\"\\u5c45\\u6c11\\u4eba\\u5747\\u53ef\\u652f\\u914d\\u6536\\u5165\\u7d2f\\u8ba1\\u503c(\\u5143)\"},\"id\":\"4504\",\"type\":\"Title\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"5331\",\"type\":\"CDSView\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5323\"}},\"fill_color\":{\"value\":\"#fdae61\"},\"line_color\":{\"value\":\"#fdae61\"},\"top\":{\"expr\":{\"id\":\"5324\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"5655\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\"]},\"id\":\"5323\",\"type\":\"Stack\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"5052\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021Q2\",\"nonselection_glyph\":{\"id\":\"5053\"},\"selection_glyph\":null,\"view\":{\"id\":\"5055\"}},\"id\":\"5054\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"4512\",\"type\":\"LinearScale\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5325\"}},\"fill_color\":{\"value\":\"#d7191c\"},\"line_color\":{\"value\":\"#d7191c\"},\"top\":{\"expr\":{\"id\":\"5326\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"5764\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"2022Q1\"]},\"id\":\"5921\",\"type\":\"Stack\"},{\"attributes\":{},\"id\":\"4515\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\",\"2021Q2\"]},\"id\":\"5927\",\"type\":\"Stack\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5319\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#abdda4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#abdda4\"},\"top\":{\"expr\":{\"id\":\"5320\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"5438\",\"type\":\"VBar\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"6367\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021Q1\",\"nonselection_glyph\":{\"id\":\"6368\"},\"selection_glyph\":null,\"view\":{\"id\":\"6370\"}},\"id\":\"6369\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"4510\",\"type\":\"CategoricalScale\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"4943\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021Q3\",\"nonselection_glyph\":{\"id\":\"4944\"},\"selection_glyph\":null,\"view\":{\"id\":\"4946\"}},\"id\":\"4945\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"end\":300000,\"start\":0},\"id\":\"4508\",\"type\":\"DataRange1d\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\"]},\"id\":\"5924\",\"type\":\"Stack\"},{\"attributes\":{\"formatter\":{\"id\":\"4556\"},\"minor_tick_line_color\":null,\"ticker\":{\"id\":\"4515\"}},\"id\":\"4514\",\"type\":\"CategoricalAxis\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4720\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#fdae61\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#fdae61\"},\"top\":{\"expr\":{\"id\":\"4721\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"5053\",\"type\":\"VBar\"},{\"attributes\":{\"factors\":[\"\\u5e7f\\u4e1c\\u7701\",\"\\u5317\\u4eac\",\"\\u4e0a\\u6d77\\u5e02\",\"\\u6d59\\u6c5f\\u7701\",\"\\u6c5f\\u82cf\\u7701\"],\"range_padding\":0.1},\"id\":\"4506\",\"type\":\"FactorRange\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"4946\",\"type\":\"CDSView\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5926\"}},\"fill_color\":{\"value\":\"#fdae61\"},\"line_color\":{\"value\":\"#fdae61\"},\"top\":{\"expr\":{\"id\":\"5927\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"6258\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"4521\",\"type\":\"PanTool\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"5764\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021Q1\",\"nonselection_glyph\":{\"id\":\"5765\"},\"selection_glyph\":null,\"view\":{\"id\":\"5767\"}},\"id\":\"5766\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"label\":{\"value\":\"2021Q3\"},\"renderers\":[{\"id\":\"4579\"},{\"id\":\"4945\"},{\"id\":\"5548\"},{\"id\":\"6151\"}]},\"id\":\"4589\",\"type\":\"LegendItem\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"4521\"},{\"id\":\"4522\"},{\"id\":\"4523\"},{\"id\":\"4524\"},{\"id\":\"4525\"},{\"id\":\"4526\"},{\"id\":\"4528\"}]},\"id\":\"4529\",\"type\":\"Toolbar\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"4577\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021Q3\",\"nonselection_glyph\":{\"id\":\"4578\"},\"selection_glyph\":null,\"view\":{\"id\":\"4580\"}},\"id\":\"4579\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"4522\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"4526\",\"type\":\"HelpTool\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4718\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#ffffbf\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"4719\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"4944\",\"type\":\"VBar\"},{\"attributes\":{\"overlay\":{\"id\":\"4527\"}},\"id\":\"4523\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"4524\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"4525\",\"type\":\"ResetTool\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4543\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#fdae61\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#fdae61\"},\"top\":{\"expr\":{\"id\":\"4544\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"4592\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\"]},\"id\":\"4719\",\"type\":\"Stack\"},{\"attributes\":{\"data\":{\"2021Q1\":[12636,19585,21548,18263,15500],\"2021Q2\":[23604,38138,40357,30998,25119],\"2021Q3\":[35694,56498,58907,44712,36227],\"2021Q4\":[44993,75002,78027,57541,47498],\"2022Q1\":[13360,20630,22663,19366,16490],\"dq\":[\"\\u5e7f\\u4e1c\\u7701\",\"\\u5317\\u4eac\",\"\\u4e0a\\u6d77\\u5e02\",\"\\u6d59\\u6c5f\\u7701\",\"\\u6c5f\\u82cf\\u7701\"]},\"selected\":{\"id\":\"1503\"},\"selection_policy\":{\"id\":\"1502\"}},\"id\":\"1446\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"4591\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021Q2\",\"nonselection_glyph\":{\"id\":\"4592\"},\"selection_glyph\":null,\"view\":{\"id\":\"4594\"}},\"id\":\"4593\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"4554\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"5767\",\"type\":\"CDSView\"},{\"attributes\":{\"callback\":null,\"tooltips\":\"\\u53ef\\u652f\\u914d\\u6536\\u5165\\u7d2f\\u8ba1\\u503c @dq: @$name\"},\"id\":\"4528\",\"type\":\"HoverTool\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\"]},\"id\":\"4717\",\"type\":\"Stack\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4539\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#abdda4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#abdda4\"},\"top\":{\"expr\":{\"id\":\"4540\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"4564\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\"]},\"id\":\"4718\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"2022Q1\"]},\"id\":\"4716\",\"type\":\"Stack\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4718\"}},\"fill_color\":{\"value\":\"#ffffbf\"},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"4719\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"4943\",\"type\":\"VBar\"},{\"attributes\":{\"label\":{\"value\":\"2021Q2\"},\"renderers\":[{\"id\":\"4593\"},{\"id\":\"5054\"},{\"id\":\"5657\"},{\"id\":\"6260\"}]},\"id\":\"4603\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"4556\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"4527\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"4728\",\"type\":\"CDSView\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4714\"}},\"fill_color\":{\"value\":\"#2b83ba\"},\"line_color\":{\"value\":\"#2b83ba\"},\"top\":{\"expr\":{\"id\":\"4715\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"4725\",\"type\":\"VBar\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"4563\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2021Q4\",\"nonselection_glyph\":{\"id\":\"4564\"},\"selection_glyph\":null,\"view\":{\"id\":\"4566\"}},\"id\":\"4565\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\",\"2021Q2\"]},\"id\":\"4722\",\"type\":\"Stack\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4716\"}},\"fill_color\":{\"value\":\"#abdda4\"},\"line_color\":{\"value\":\"#abdda4\"},\"top\":{\"expr\":{\"id\":\"4717\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"4834\",\"type\":\"VBar\"},{\"attributes\":{\"label\":{\"value\":\"2021Q4\"},\"renderers\":[{\"id\":\"4565\"},{\"id\":\"4836\"},{\"id\":\"5439\"},{\"id\":\"6042\"}]},\"id\":\"4575\",\"type\":\"LegendItem\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\",\"2021Q2\",\"2021Q1\"]},\"id\":\"4723\",\"type\":\"Stack\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4541\"}},\"fill_color\":{\"value\":\"#ffffbf\"},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"4542\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"4577\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\"]},\"id\":\"4720\",\"type\":\"Stack\"},{\"attributes\":{\"items\":[{\"id\":\"4561\"},{\"id\":\"4575\"},{\"id\":\"4589\"},{\"id\":\"4603\"},{\"id\":\"4617\"}],\"location\":\"top_left\",\"orientation\":\"horizontal\"},\"id\":\"4560\",\"type\":\"Legend\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\"]},\"id\":\"4543\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\",\"2021Q2\"]},\"id\":\"4721\",\"type\":\"Stack\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"4580\",\"type\":\"CDSView\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"5325\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#d7191c\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#d7191c\"},\"top\":{\"expr\":{\"id\":\"5326\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"5765\",\"type\":\"VBar\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"4551\",\"type\":\"CDSView\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"5931\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2022Q1\",\"nonselection_glyph\":{\"id\":\"5932\"},\"selection_glyph\":null,\"view\":{\"id\":\"5934\"}},\"id\":\"5933\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"4594\",\"type\":\"CDSView\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\",\"2021Q2\"]},\"id\":\"4544\",\"type\":\"Stack\"},{\"attributes\":{\"data_source\":{\"id\":\"1446\"},\"glyph\":{\"id\":\"4548\"},\"hover_glyph\":null,\"muted_glyph\":null,\"name\":\"2022Q1\",\"nonselection_glyph\":{\"id\":\"4549\"},\"selection_glyph\":null,\"view\":{\"id\":\"4551\"}},\"id\":\"4550\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4543\"}},\"fill_color\":{\"value\":\"#fdae61\"},\"line_color\":{\"value\":\"#fdae61\"},\"top\":{\"expr\":{\"id\":\"4544\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"4591\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\",\"2021Q2\"]},\"id\":\"4545\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"2022Q1\",\"2021Q4\",\"2021Q3\",\"2021Q2\",\"2021Q1\"]},\"id\":\"4546\",\"type\":\"Stack\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4537\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#2b83ba\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#2b83ba\"},\"top\":{\"expr\":{\"id\":\"4538\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"4549\",\"type\":\"VBar\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4537\"}},\"fill_color\":{\"value\":\"#2b83ba\"},\"line_color\":{\"value\":\"#2b83ba\"},\"top\":{\"expr\":{\"id\":\"4538\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"4548\",\"type\":\"VBar\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4541\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#ffffbf\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"4542\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"4578\",\"type\":\"VBar\"},{\"attributes\":{\"label\":{\"value\":\"2022Q1\"},\"renderers\":[{\"id\":\"4550\"},{\"id\":\"4727\"},{\"id\":\"5330\"},{\"id\":\"5933\"}]},\"id\":\"4561\",\"type\":\"LegendItem\"},{\"attributes\":{\"label\":{\"value\":\"2021Q1\"},\"renderers\":[{\"id\":\"4607\"},{\"id\":\"5163\"},{\"id\":\"5766\"},{\"id\":\"6369\"}]},\"id\":\"4617\",\"type\":\"LegendItem\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"4539\"}},\"fill_color\":{\"value\":\"#abdda4\"},\"line_color\":{\"value\":\"#abdda4\"},\"top\":{\"expr\":{\"id\":\"4540\"}},\"width\":{\"value\":0.9},\"x\":{\"field\":\"dq\"}},\"id\":\"4563\",\"type\":\"VBar\"},{\"attributes\":{\"source\":{\"id\":\"1446\"}},\"id\":\"4566\",\"type\":\"CDSView\"}],\"root_ids\":[\"4503\"]},\"title\":\"Bokeh Application\",\"version\":\"2.1.1\"}};\n",
       "  var render_items = [{\"docid\":\"5cccb0c6-738d-4a6a-a812-4691f4b9e1ae\",\"root_ids\":[\"4503\"],\"roots\":{\"4503\":\"85e44f37-34cb-4f3b-9be2-567c7bf315d7\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        clearInterval(timer);\n",
       "        embed_document(root);\n",
       "      } else {\n",
       "        attempts++;\n",
       "        if (attempts > 100) {\n",
       "          clearInterval(timer);\n",
       "          console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        }\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "4503"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘图\n",
    "p.vbar_stack(\n",
    "    years, \n",
    "    x='dq', \n",
    "    width=0.9, \n",
    "    color=colors, \n",
    "    source=source,\n",
    "    legend=[value(x) for x in years]    \n",
    ")\n",
    "\n",
    "# 其他\n",
    "p.y_range.start = 0\n",
    "p.y_range.end = 300000\n",
    "p.x_range.range_padding = 0.1\n",
    "p.xgrid.grid_line_color = None\n",
    "p.axis.minor_tick_line_color = None\n",
    "p.outline_line_color = None\n",
    "p.legend.location = \"top_left\"\n",
    "p.legend.orientation = \"horizontal\"\n",
    "\n",
    "# 显示\n",
    "show(p)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
